using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using JSON;

public class JSONMonsterBuff{
	#region 单例
	private static JSONMonsterBuff instance;
	public static JSONMonsterBuff getInstance(){
	if (instance == null)
		instance = new JSONMonsterBuff ();
		return instance;
	}
	#endregion

	#region 变量
	private JSONNode json;
	private JSONNode JSONData{
		get{
			if(json == null)
				json = JsonRead.Read("JSONMonsterBuff");
			return json;
		}
	}
	#endregion
	#region 外部调用
	public void Clear(){
		json = null;
	}
	public JSONNode GetJSON(string key){
		return JSONData [key];
	}
	public JSONNode GetJSON(int index){
		return JSONData [index];
	}
	/// <summary>
	/// 有多少个数据
	/// </summary>
	public int GetCount(){
	return JSONData.Count;
	}

    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListID(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetID(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 
	/// </summary>
	public int GetID(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["ID"].AsInt;
		return  value;
	}
	/// <summary>
	///  :From Index
	/// </summary>
	public int GetID(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetID(index.ToString());
			return  value;
		}
		value = json["ID"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListBuffType(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetBuffType(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 
	/// </summary>
	public int GetBuffType(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["BuffType"].AsInt;
		return  value;
	}
	/// <summary>
	///  :From Index
	/// </summary>
	public int GetBuffType(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetBuffType(index.ToString());
			return  value;
		}
		value = json["BuffType"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListBuffName(string target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetBuffName(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 中文名
	/// </summary>
	public string GetBuffName(string key){
		JSONNode json = GetJSON (key);
		string  value;
		value = json["BuffName"].ToString();
		return  value;
	}
	/// <summary>
	/// 中文名 :From Index
	/// </summary>
	public string GetBuffName(int index){
		string value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetBuffName(index.ToString());
			return  value;
		}
		value = json["BuffName"].ToString();
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListPrefabName(string target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetPrefabName(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 字段名
	/// </summary>
	public string GetPrefabName(string key){
		JSONNode json = GetJSON (key);
		string  value;
		value = json["PrefabName"].ToString();
		return  value;
	}
	/// <summary>
	/// 字段名 :From Index
	/// </summary>
	public string GetPrefabName(int index){
		string value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetPrefabName(index.ToString());
			return  value;
		}
		value = json["PrefabName"].ToString();
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListBuffLife(float target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetBuffLife(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 持续时间
	/// </summary>
	public float GetBuffLife(string key){
		JSONNode json = GetJSON (key);
		float  value;
		value = json["BuffLife"].AsFloat;
		return  value;
	}
	/// <summary>
	/// 持续时间 :From Index
	/// </summary>
	public float GetBuffLife(int index){
		float value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetBuffLife(index.ToString());
			return  value;
		}
		value = json["BuffLife"].AsFloat;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListBuffStart(string target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetBuffStart(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// buff开始
	/// </summary>
	public string GetBuffStart(string key){
		JSONNode json = GetJSON (key);
		string  value;
		value = json["BuffStart"].ToString();
		return  value;
	}
	/// <summary>
	/// buff开始 :From Index
	/// </summary>
	public string GetBuffStart(int index){
		string value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetBuffStart(index.ToString());
			return  value;
		}
		value = json["BuffStart"].ToString();
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListBuffStay(string target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetBuffStay(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 
	/// </summary>
	public string GetBuffStay(string key){
		JSONNode json = GetJSON (key);
		string  value;
		value = json["BuffStay"].ToString();
		return  value;
	}
	/// <summary>
	///  :From Index
	/// </summary>
	public string GetBuffStay(int index){
		string value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetBuffStay(index.ToString());
			return  value;
		}
		value = json["BuffStay"].ToString();
		return  value;
	}

	#endregion
}